package cn.tedu.cinema.order.controller;

import cn.tedu.cinema.base.response.JsonResult;
import cn.tedu.cinema.order.pojo.dto.OrderParam;
import cn.tedu.cinema.order.pojo.entity.Order;
import cn.tedu.cinema.order.service.OrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/v1/order")
public class OrderController {

    @Autowired
    private OrderService orderService;
    @PostMapping("/create")
    public JsonResult createOrder(@RequestBody OrderParam orderParam){

        Order order = new Order();
        BeanUtils.copyProperties(orderParam,order);
        order.setPayMethod(1);
        order.setOrderStatus(0);
        order.setPayTime(new Date());
        orderService.createOrder(order);


        return JsonResult.ok();
    }

}
